package com.wwj.auction.admin.controller;


import com.wwj.auction.admin.entity.vo.PageModel;
import com.wwj.auction.admin.entity.vo.UserInfoVo;
import com.wwj.auction.admin.service.UserInfoService;
import com.wwj.auction.common.result.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wwj
 * @since 2021-08-25
 */
@RestController
@RequestMapping("/admin/userInfo")
public class UserInfoController {

    @Autowired
    private UserInfoService userInfoService;

    /**
     * 分页查询买家、卖家用户信息，若是携带查询条件，还需进行条件筛选
     *
     * @param page
     * @param limit
     * @param params
     * @return
     */
    @GetMapping("/list/buyer/{userType}/{page}/{limit}")
    public R listForBuyer(
            @PathVariable("userType") Integer userType,
            @PathVariable("page") Integer page,
            @PathVariable("limit") Integer limit,
            @RequestParam Map<String, Object> params) {
        PageModel<UserInfoVo> pageModel = userInfoService.listForBuyer(page, limit, params, userType);
        return R.ok().data("pageModel", pageModel);
    }

    /**
     * 对用户进行锁定或解锁
     *
     * @param id
     * @param status
     * @return
     */
    @PutMapping("/lock/{id}/{status}")
    public R lock(
            @PathVariable("id") Integer id,
            @PathVariable("status") Integer status) {
        userInfoService.lock(id, status);
        return R.ok().message("操作成功");
    }

    /**
     * 对店铺进行查封或解封
     *
     * @param id
     * @param status
     * @return
     */
    @PutMapping("/lockStore/{id}/{status}")
    public R lockStore(
            @PathVariable("id") Integer id,
            @PathVariable("status") Integer status) {
        userInfoService.lockStore(id, status);
        return R.ok().message("操作成功");
    }
}

